package com.base.core.utils;

import java.lang.reflect.Proxy;

/**
 * 动态代理工具类.
 */
public class ProxyHandlerUtils {

    public <T> T createProxy(Class<T> targetInterface) {
        try {
           return  (T) Proxy.newProxyInstance(targetInterface.getClassLoader(), new Class[]{targetInterface},
                    (proxy, method, args) -> {
                        Object invoke = method.invoke(targetInterface, args);
                        return invoke;
                    });
        }catch (Exception e){
            throw e;
        }
    }
}

